home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Commodore Free 23
/
Commodore_Free_Issue_23_2008_Commodore_Computer_Club.d64
/
t.b guide 8.2
< prev
next >
Wrap
Text File
|
2023-02-26
|
12KB
|
369 lines
u
In the Beginning Chapter 8 Section 2
-------------------------
\Lord Ronin from Q-Link\
Don't worry if my explanation of how
that maze is being created doesn't
make a lot of sense, I think that it
is a bit too advanced for this level.
It took me 7 times through the book
working with others to even have a
remote idea on how the process works.
What the important point is that you
can print the chr$ as well as the
reverse. This is done as follows.
?ASC("Z")
Press RETURN
90 will appear on the screen.
?CHR$(92)
Press RETURN
\ will appear on the screen.
Try a few of these on your own, there
are books, reference cards and other
places where the lists of the
characters and codes are already
listed. Still it is a way to have a
little fun and get more of a feel for
the system. A way to see the actual
character from the keyboard as well as
finding the ascii value. OK here we
have a time problem, I quote from the
book. "As you probably figured out,
'ASC' is another function, which
returns the standard 'ASCII' code type
for the character you typed."
Early on in this collection of drivel
I said something about the characters
ascii and PETascii. Ascii and PETascii
are different animals, lets not worry
what the initials stand for in this
case, only that there is a gigantic
difference. Saying that we come to the
point of what is really "Standard".
Because, obviously there isn't a
"real" standard, making a ruling now,
PETascii is the Commodore standard and
normal ascii is the standard used by
the IBM pc! Clear for that, PETascii
is what we are learning about, so it
must be the only standard we need
right? And yes I am biased towards the
C=.
Going by the book we just moved into
Chapter 5 "Advanced Colour and Graphic
Commands" Lets jump right in, even
with the personal thought that we
aren't really that advanced. I mean I
have never thought that I was that
"Advanced" any time I had reached this
point in the manual. Here they start
you off telling you the colours for
the control and the C= key, we already
covered this a bit earlier on in the
series. You remember the bit about
using the Control key and the number
keys to make the first 8 colours, then
the C= key and the numbers for the
next 8 colours. In order to illustrate
this in the book there is a little one
line programme they want you to enter
and run.
10 ?"RAINBOW"
What they want you to do is change the
colour for each letter by pressing the
control and keys 1-7. Doing that in
front of each letter and using the
numbers in that order, yeah they want
control and 1 before the R control and
7 before the W. Then run the programme
and you will see the word printed in
different coloured letters on screen.
The rest of page 57 is taken up with
a chart that shows you the character
gfx symbol that appears in a print
statements, all 16 of them. Sorry the
writing tool I am using doesn't have
all those gfx characters in the set,
since I am using the upper and lower
case letters. You can experiment on
that at this point if you don't have a
list, creating your own list; OK I
don't bother with that myself. Only
look at the word on the number key for
the colour and press that key in the
print statement, but I am a lamer
programmer and lazy to boot. At this
point in the book and therefore the
series of articles we are going to run
into this symbol problem in different
ways, Seen by this short program they
have you type in.
new
10 ?CHR$(147): REM CLEAR HOME
20 ?CHR$(30);"CHR$(30) CHANGES ME TO ?"
RUN
Well you don't have a chart of the
character strings, do you? I'm working
on the assumption that you don't, at
least at this moment. I believe that
there is a place online that has the
manual for Down Loading. This list of
codes are in the appendix in he back
of the manual and in the Programmers
Reference Guide. As well as in some of
the type in books I have seen. Those
of you who do have these charts, they
are the ones that are ladled "Screen
Display Codes", and the other one is
"Ascii and CHR$ codes. You are lucky
and I'd like you to thumb to that
section from time to time. Right now
we are dealing with the "Ascii and
CHR$ Codes" one.
OK back to that little programme.
Line 10
This gives you the CHR$ for the
shifted clear home, Note that the
number is always in the () symbols.
Well my level and understanding of
programming has me looking at that and
counting the spaces. Counting the
print command as the ? symbol, that is
9 spaces taken up. Using the ? and the
shifted clear home in the quotes takes
up 4 spaces. Seems this last style is
more effective in spaces. More
experienced programmers can tell me if
I am right or wrong on this thought. I
have seen the chr$(147) in type in
programmes and substituted the shifted
clear home, didn't appear to me to do
anything different in the prg.
Line 20
This will print that character string
and then the words in the quotes
notice that there is nothing for you
to do for a real answer, which is
green, before I go to a complicated
programme for you to type in. I should
tell you something, a short hand way
to write CHR$, which is cH. Well that
is how it looks in lower case. Upper
case would have the capital C and a
vertical bar. Still have to type in
the () things with the number between
them though.
Next is a colour bar programme. I have
a few things to say before you have a
go at typing it into the C=. Running
this will create a series of reverse
video colour bars on the screen. They
will run till you press the run/stop
key, only does the first 8 colours of
the commodores 16 and uses the chr$
codes. If you feel like experimenting
and have the chart, feel free to
expand this to the full16 colours. We
have covered the rudiments for how to
do that except for a command that is
new to us at this point and I will get
to that afterwards. I did make this as
the 16 colours the tool that I use to
test the colour chip and monitors when
they come into my collection.
The final part is a lesson on editing;
you will see that there are many lines
here that are close to being the same.
OK lines 40-110. I'll explain about
editing, after you see the programme,
but wait to type it in, and you will
save some fingers.
Type NEW then press RETURN
1 REM AUTOMATIC COLOR BARS
5 ?CHR$(147)
10 ?CHR$(18);" ";
20 CL=INT(8*RND(1))+1
30 ON CL GOTO 40.50,60,70,80,90,100,
110
40 ?CHR$(5);:GOTO10
50 ?CHR$(28);:GOTO10
60 ?CHR$(30);:GOTO10
70 ?CHR$(31);:GOTO10
80 ?CHR$(144);:GOTO10
90 ?CHR$(156);:GOTO10
100 ?CHR$(158);:GOTO10
110 ?CHR$(159);:GOTO10
Before any explanation lets save your
fingers editing time with the C=. Type
in line 40 you can see how much it is
the same as the other lines below it,
so how to avoid typing all that drenn
over and over again? Well after you
type line 40. Oh yeah make absolutely
certain that you hit the return key
[lightly of course] after you complete
each line. Return takes you to just
underneath the 4 in 40, cursor up to
that 4, and now type a 5 over it.
Right the line now reads 50, don't
panic yet cursor over to the 5 in the
() symbols. Use a shifted inst/del key
this makes a space. Creating a two
character area in between the ()
symbols. Type in the 2 and right over
the 5 you see there type the 8. Now
the line reads right for line 50.
Press return and then cursor up,
change the 5 to a 6. Type over the 28
making changing it to 30 press RETURN
and you have line 60 done. Repeat this
till you have all the lines completed.
Panic time? No not really, if you did
it as above, then you will be sitting
on line 110 with the cursor under the
1 sure you are panicking about the
other lines, so I want you to type
either LIST then press return. Why
there is the complete programme!
Editing here is that you log in or
record the line as written with the
line number, each time you press
return you add the line to memory. You
can also type in line numbers out of
linear sequence but they will all show
up in the programme in nice neat
linear number fashion when the program
is Listed to screen.
So what is happening in this
programme? After you run it you will
see the 5 space colour bars go across
the screen and down one line, pretty
fast considering the speed of the
machine <VBG>. Well we have covered
line 1, the REM statement. We have
covered line 5 the clear home CHR$.
Line 10 is a tad bit different, here
you tell it to print a character
string; this one being 18, that is the
command to turn on reverse video with
a character string. A semicolon
follows, so things will stay on the
same line and be connected, that is
why the colour bars are butted against
each other, no spaces and no one
colour bar, then it drops to the next
line. In the quotes are 5 spaces, just
a number I took from the book, you can
make it larger or smaller for some
interesting effects. At 20 we have
that variable and a random number
generator, as you see the number in
there is 8, so we are creating 8
separate numbers. Line 30 has a new
command, the ON command, before I go
to the how it works, think what the
programme would look like if you used
IF THEN statements.
40 IF CL=1 THEN?CHR$(5):GOTO10
Right you would have to do that for
each of the 8 lines, of course you
would be writing 8 lines of IF THEN
and a line about getting the CL, and
well you can see it is confusing.
Using the ON command is a little hard
and confusing at first, the majority
of people in programming Basic that I
respect, advocate the ON command.
Saying that, here is how it works, as
simply as I can state. The Line is
saying that on the CL variable, the
computer is to goto a specific line.
So lets say that the random number
generator creates for CL a 7, we do
what and where? Right I understand the
confusion, I had that problem for a
long time a mental block. What helped
me is to count the things in the rest
of the line, here it reads 40-110.
Yeah those commas are mandatory. Hmm
seems to be that there are 8 of them,
well the generator makes only 8
numbers. The Amount of things to goto
must equal the amount created with the
generator. Personally I got messed up
with the numbers and other things for
the goto part, blocking me from
gaining even this little understanding.
Ok so back to my example, the
generator has created for the variable
CL a number 7, So on CL, or read that
as ON 7 GOTO 100, this is because that
is the 7th number in the line. Got it,
generate a 4 and it goes to the 4th
number in the line. 1 would be the
first number, and so forth. Don't ask
how long it took for me to understand
that one. <S> OK you are brighter than
me, bet you can see that in certain
forms of games, you can have the ON
statement take the programme to a
print statement and have specific text
appear.
After the above example, the book now
on page 60 starts at the bottom with
the idea of PEEKS and POKES do.
Honestly this is a hard one for me,
not that I don't know what they are, I
don't know WHAT they are. Got you
confused yet? <G> Well OK what I mean
is that I know that a POKE or in short
hand a pO, Sticks something into the
computer memory, the book uses the
idea of boxes. Other books talk about
egg crates, and others the old
fashioned roll top desk with all the
little letter sized pigeon holes, all
trying to give you a visual of a lots
of storage areas that you can put a
something into. A PEEK or in short
hand pE. Is looking in as they say, to
a box or pigeon hole, and shows you
what is in there at that moment. Got
that part in the bare basics, now what
or where these places are is not in my
understanding at this time.
Showing the vacuum of my brain above.
We shall talk more on this in the next
session
CONTINUED NEXT MONTH